package com.clstu.homework;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Homework01 {
    public static void main(String[] args) throws IOException {
        String temp = "D:\\myTemp";
        File file = new File(temp);
        if(file.exists()){
            System.out.println("该文件夹已经存在~~~~~~");
        }else{
            if(file.mkdir()){
                System.out.println("文件夹创建成功········");
            }else {
                System.out.println("文件夹创建失败·······~~~");
            }
        }
        String filePath = temp + "\\hello.txt";
        File file1 = new File(filePath);
        if (file1.exists()){
            System.out.println("文件"+filePath+"已经存在~~");
        }else {
            if (file1.createNewFile()){
                System.out.println("文件创建成功~~~~~~~~");
            }else {
                System.out.println("文件创建失败");
            }
        }
        if(file1.exists()){
            System.out.println("现在文件hello.txt已经存在");
        }else {
            System.out.println("现在文件hello.txt不存在");
        }
//        FileWriter fileWriter = new FileWriter(filePath);
//        fileWriter.write("hello,玛卡巴卡");
//        fileWriter.close();
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(filePath));
        bufferedWriter.write("hello 啊 玛卡巴卡 ~~~");
        bufferedWriter.close();
        System.out.println("文件写入成功~~~~~~~~~");
    }
}
